package com.sky.controller.employee;

import com.sky.constant.StatusChangeConstant;
import com.sky.result.Result;
import com.sky.service.RoomStatusChangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/employee/meetingRoomStatusChange")
@Slf4j
@CrossOrigin
@Builder
@Api(tags = "会议室状态管理")
public class RoomStatusChangeController {
    @Autowired
    private RoomStatusChangeService roomStatusChangeService;

    @PostMapping("/changeStatusBU/{id}")
    @ApiOperation(value = "会议室状态: 预定 -> 使用")
    public Result changeStatusBU(@PathVariable("id") Long id) {
        if (roomStatusChangeService.changeStatusBU(id)) {
            return Result.success();
        } else {
            return Result.error(StatusChangeConstant.StatusChangeError);
        }
    }

    @PostMapping("/changeStatusUF/{id}")
    @ApiOperation(value = "会议室状态: 使用 -> 空闲")
    public Result changeStatusUF(@PathVariable("id") Long id) {
        if (roomStatusChangeService.changeStatusUF(id)) {
            return Result.success();
        } else {
            return Result.error(StatusChangeConstant.StatusChangeError);
        }
    }

    @PostMapping("/changeStatusUS/{id}")
    @ApiOperation(value = "会议室状态: 使用 -> 维护")
    public Result changeStatusUS(@PathVariable("id") Long id) {
        if (roomStatusChangeService.changeStatusUS(id)) {
            return Result.success();
        } else {
            return Result.error(StatusChangeConstant.StatusChangeError);
        }
    }

    @PostMapping("/changeStatusSF/{id}")
    @ApiOperation(value = "会议室状态: 维护 -> 空闲")
    public Result changeStatusSF(@PathVariable("id") Long id) {
        if (roomStatusChangeService.changeStatusSF(id)) {
            return Result.success();
        } else {
            return Result.error(StatusChangeConstant.StatusChangeError);
        }
    }

}
